let state = {
    items:[]
}

let actions = {
    addToCart({state,commit},product){
        if(product.inventory > 0){
            const cartItem = state.items.find(item => item.id === product.id);
            if(!cartItem){
                commit('pushProduct',{id:product.id})
            }else{
                commit('increment',cartItem);
            }
        }
    }
}

let mutations = {
    pushProduct(state,{id}){
        
    },
    increment(){

    }
}


export default {
    namespaced: true,
    state
}